package com.ruoyi.controller;


import com.ruoyi.domain.OnlineShow;
import com.ruoyi.platform.annotation.Log;
import com.ruoyi.platform.core.controller.BaseController;
import com.ruoyi.platform.core.domain.AjaxResult;
import com.ruoyi.platform.core.page.TableDataInfo;
import com.ruoyi.platform.enums.BusinessType;
import com.ruoyi.platform.utils.poi.ExcelUtil;
import com.ruoyi.service.IOnlineShowService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 在线演示Controller
 *
 * @author tp
 * @date 2022-11-02
 */
@RestController
@RequestMapping("/admin/show")
@Api(tags = {"在线演示服务"})
public class OnlineShowController extends BaseController
{
    @Autowired
    private IOnlineShowService onlineShowService;

/**
 * 查询在线演示列表
 */
@PreAuthorize("@ss.hasPermi('admin:show:list')")
@GetMapping("/list")
@ApiOperation(value="查询在线演示列表", httpMethod = "GET", notes = "查询在线演示列表")
    public TableDataInfo list(OnlineShow onlineShow)
    {
        startPage();
        List<OnlineShow> list = onlineShowService.selectOnlineShowList(onlineShow);
        return getDataTable(list);
    }

    /**
     * 导出在线演示列表
     */
    @PreAuthorize("@ss.hasPermi('admin:show:export')")
    @Log(title = "在线演示", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ApiOperation(value="导出在线演示列表", httpMethod = "POST", notes = "导出在线演示列表")
    public void export(HttpServletResponse response, OnlineShow onlineShow)
    {
        List<OnlineShow> list = onlineShowService.selectOnlineShowList(onlineShow);
        ExcelUtil<OnlineShow> util = new ExcelUtil<OnlineShow>(OnlineShow.class);
        util.exportExcel(response, list, "在线演示数据");
    }

    /**
     * 获取在线演示详细信息
     */
    @PreAuthorize("@ss.hasPermi('admin:show:query')")
    @GetMapping(value = "/{id}")
    @ApiOperation(value="获取在线演示详细信息", httpMethod = "GET", notes = "获取在线演示详细信息")
    public AjaxResult getInfo(@PathVariable("id") Integer id)
    {
        return AjaxResult.success(onlineShowService.selectOnlineShowById(id));
    }

    /**
     * 新增在线演示
     */
    @PreAuthorize("@ss.hasPermi('admin:show:add')")
    @Log(title = "在线演示", businessType = BusinessType.INSERT)
    @PostMapping
    @ApiOperation(value="新增在线演示", httpMethod = "POST", notes = "新增在线演示")
    public AjaxResult add(@RequestBody OnlineShow onlineShow)
    {
        return toAjax(onlineShowService.insertOnlineShow(onlineShow));
    }

    /**
     * 修改在线演示
     */
    @PreAuthorize("@ss.hasPermi('admin:show:edit')")
    @Log(title = "在线演示", businessType = BusinessType.UPDATE)
    @PutMapping
    @ApiOperation(value="修改在线演示", httpMethod = "PUT", notes = "修改在线演示")
    public AjaxResult edit(@RequestBody OnlineShow onlineShow)
    {
        return toAjax(onlineShowService.updateOnlineShow(onlineShow));
    }

    /**
     * 删除在线演示
     */
    @PreAuthorize("@ss.hasPermi('admin:show:remove')")
    @Log(title = "在线演示", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    @ApiOperation(value="删除在线演示", httpMethod = "DELETE", notes = "删除在线演示")
    public AjaxResult remove(@PathVariable Integer[] ids)
    {
        return toAjax(onlineShowService.deleteOnlineShowByIds(ids));
    }
}
